public class Test {
    public static void salCompute(Employee employee){
        if(employee instanceof Worker){
            ((Worker) employee).study();
        }else if (employee instanceof Manager){
            ((Manager) employee).manage();
        }
        employee.addSalary();
    }

    public static void main(String[] args) {
        Employee employee = new Worker();
        Employee employee1 = new Manager();

        Employee[] employees = new Employee[]{employee,employee1};

        for (Employee employee2: employees){
            salCompute(employee2);
        }
    }
}
